package cn.lintcode;

import java.io.*;
import java.security.MessageDigest;
import java.util.Arrays;

/**
 * @author labvi
 * @version 1.0.0
 */
public class MergeArray {
    private final static PrintWriter out = new PrintWriter(System.out);
    private final static BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
    private final static StreamTokenizer scanner = new StreamTokenizer(bufferedReader);
    public static String merge(int[] arr1, int[] arr2){
        int[] result = new int[arr1.length+arr2.length];
        int i = 0,j = 0,cur = 0;
        while (i < arr1.length && j < arr2.length){
            if (arr1[i] < arr2[j]) {
                result[cur++] = arr1[i++];
            } else {
                result[cur++] = arr2[j++];
            }
        }
        while (i < arr1.length){
            result[cur++] = arr1[i++];
        }
        while (j < arr2.length){
            result[cur++] = arr2[j++];
        }
        return Arrays.toString(result);
    }

    /*public static void main(String[] args) throws IOException {
        scanner.nextToken();
        int i = (int)scanner.nval;
        int[] arr1 = new int[i];
        for (int j = 0; j < i; j++) {
            scanner.nextToken();
            arr1[j] = (int)scanner.nval;
        }
        scanner.nextToken();
        i = (int)scanner.nval;
        int[] arr2 = new int[i];
        for (int j = 0; j < i; j++) {
            scanner.nextToken();
            arr2[j] = (int)scanner.nval;
        }
        String merge = merge(arr1,arr2);
        out.println(toMD5(merge));
        out.flush();
    }*/

    public static void main(String[] args) throws IOException {
        String s = bufferedReader.readLine();
        int i = Integer.valueOf(s);
        int[] arr1 = new int[i];
        for (int j = 0; j < i; j++) {
            Integer integer = Integer.valueOf(bufferedReader.readLine());
            arr1[j] = integer;
        }
        s = bufferedReader.readLine();
        i = Integer.valueOf(s);
        int[] arr2 = new int[i];
        for (int j = 0; j < i; j++) {
            Integer integer = Integer.valueOf(bufferedReader.readLine());
            arr2[j] = integer;
        }
        String merge = merge(arr1,arr2);
        out.println(toMD5(merge));
        out.flush();
        bufferedReader.close();
    }

    public static String toMD5(String plainText) {
        String result = "";
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(plainText.getBytes());
            byte b[] = md.digest();
            int i;
            StringBuffer buf = new StringBuffer("");
            for (int offset = 0; offset < b.length; offset++) {
                i = b[offset];
                if (i < 0){
                    i += 256;
                }
                if (i < 16) {
                    buf.append("0");
                }
                buf.append(Integer.toHexString(i));
            }
            result = buf.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }
}
